using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace DataLayerTest.Models.Mapping
{
    public class SetTopBoxMap : EntityTypeConfiguration<SetTopBox>
    {
        public SetTopBoxMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.SerialNumber)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MAC)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("SetTopBox");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SerialNumber).HasColumnName("SerialNumber");
            this.Property(t => t.IdAdministrator).HasColumnName("IdAdministrator");
            this.Property(t => t.MAC).HasColumnName("MAC");

            // Relationships
            this.HasRequired(t => t.Administrator)
                .WithMany(t => t.SetTopBoxes)
                .HasForeignKey(d => d.IdAdministrator);

        }
    }
}
